W32: Fix for commit 1f74f12d9, re-enabling decimal separator key
authorFredy Paquet <fredy@opag.ch>
Fri, 26 Feb 2016 17:21:26 +0000 (17:21 +0000)
committerРуслан Ижбулатов <lrn1986@gmail.com>
Fri, 26 Feb 2016 17:24:32 +0000 (17:24 +0000)
1f74f12d9 rendered entry of keypad decimal mark unuseable for
several national keyboard layouts, this commit amends that, at
least for W32, and makes GTK+ behave more or less the same way
W32 behaves.

The patch works like this:
- When typing the first character at the keyboard or when switching
  keyboard layouts, the decimal mark character will be cached in the
  static variable "decimal_mark" within gdkkeys-win32.c

- in case of WIN32, gdk_keyval_to_unicode() asks gdkkeys-win32.c for the
  current decimal_mark when converting GDK_KEY_KP_Decimal.

https://bugzilla.gnome.org/show_bug.cgi?id=756751

gdk/gdkkeyuni.c
gdk/win32/gdkkeys-win32.c
gdk/win32/gdkprivate-win32.h

index d770737cccb369ccd5a945c68155bc3118b27b86..4b4431f9970e55a0990888c3326b5df23a29dcc3 100644 (file)
 #include "gdkkeys.h"
 #include "gdktypes.h"
 
+#ifdef GDK_WINDOWING_WIN32
+#include "win32/gdkwin32.h"
+#include "win32/gdkprivate-win32.h"
+#endif
 
 /* Thanks to Markus G. Kuhn <mkuhn@acm.org> for the ksysym<->Unicode
  * mapping functions, from the xterm sources.
@@ -899,6 +903,14 @@ gdk_keyval_to_unicode (guint keyval)
   if ((keyval & 0xff000000) == 0x01000000)
     return keyval & 0x00ffffff;
 
+#if defined(GDK_WINDOWING_WIN32)
+  if (GDK_IS_WIN32_DISPLAY (gdk_display_get_default ()))
+    {
+      if (keyval == 0xffae)
+        return (guint32) _gdk_win32_keymap_get_decimal_mark ();
+    }
+#endif
+
   /* binary search in table */
   while (max >= min) {
     mid = (min + max) / 2;
index b77edb713750d1133814c6a7a80bbc99879a3267..e1ad6cfda4f62cb5455dd6dd5978cffea1b8b085 100644 (file)
@@ -64,6 +64,7 @@ static GdkModifierType gdk_shift_modifiers = GDK_SHIFT_MASK;
 static GdkKeymap *default_keymap = NULL;
 
 static guint *keysym_tab = NULL;
+static wchar_t decimal_mark = 0;
 
 #define KEY_STATE_SIZE 256
 
@@ -348,6 +349,18 @@ handle_dead (guint  keysym,
     }
 }
 
+/* keypad decimal mark depends on active keyboard layout
+ * return current decimal mark as unicode character
+ */
+guint32
+_gdk_win32_keymap_get_decimal_mark (void)
+{
+  if (decimal_mark)
+    return (decimal_mark);
+
+  return ((guint32) '.');
+}
+
 static void
 update_keymap (void)
 {
@@ -401,7 +414,7 @@ update_keymap (void)
               */
              handle_special (vk, ksymp, shift);
 
-             if (*ksymp == 0)
+             if ((*ksymp == 0) || ((vk == VK_DECIMAL) && (shift == 0)))
                {
                  wchar_t wcs[10];
                  gint k;
@@ -415,7 +428,12 @@ update_keymap (void)
                           vk, scancode, shift, k,
                           wcs[0], wcs[1]);
 #endif
-                 if (k == 1)
+                 if ((vk == VK_DECIMAL) && (shift == 0))
+                   {
+                     if (k == 1)
+                       decimal_mark = wcs[0];
+                   }
+                 else if (k == 1)
                    *ksymp = gdk_unicode_to_keyval (wcs[0]);
                  else if (k == -1)
                    {
index 292ea5f521f8254f54b849b4cfeb1d46bc19f8bc..fbce80b7724a590440379cdbae581d8fba261810 100644 (file)
@@ -533,6 +533,8 @@ gchar *_gdk_win32_display_manager_get_atom_name (GdkDisplayManager *manager,
 void _gdk_win32_append_event (GdkEvent *event);
 void _gdk_win32_emit_configure_event (GdkWindow *window);
 
+guint32 _gdk_win32_keymap_get_decimal_mark (void);
+
 /* Initialization */
 void _gdk_win32_windowing_init (void);
 void _gdk_screen_init_root_window (GdkWin32Screen *screen_win32);